API: remove gdk_draw_polygon()
authorBenjamin Otte <otte@redhat.com>
Wed, 14 Jul 2010 17:23:45 +0000 (19:23 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 10 Aug 2010 19:02:27 +0000 (21:02 +0200)
12 files changed:
docs/reference/gdk/gdk3-sections.txt
docs/reference/gdk/tmpl/drawing.sgml
gdk/directfb/gdkdrawable-directfb.c
gdk/gdk.symbols
gdk/gdkdraw.c
gdk/gdkdrawable.h
gdk/gdkoffscreenwindow.c
gdk/gdkpixmap.c
gdk/gdkwindow.c
gdk/quartz/gdkdrawable-quartz.c
gdk/win32/gdkdrawable-win32.c
gdk/x11/gdkdrawable-x11.c

index 5963faeab1de0b4736191dbdc8782b378271dc2f..413af2324dd88bcd2c5109982353aa0a1d53155f 100644 (file)
@@ -341,7 +341,6 @@ gdk_draw_lines
 gdk_draw_segments
 GdkSegment
 gdk_draw_rectangle
-gdk_draw_polygon
 gdk_draw_layout_line
 gdk_draw_layout_line_with_colors
 gdk_draw_layout
index 46f63f56dde048667cfd11d54a2703257afcc1b0..19290892b4eaa7a518d1b35c16915605998e43fd 100644 (file)
@@ -208,17 +208,6 @@ function.
 @height: 
 
 
-<!-- ##### FUNCTION gdk_draw_polygon ##### -->
-<para>
-</para>
-
-@drawable: 
-@gc: 
-@filled: 
-@points: 
-@n_points: 
-
-
 <!-- ##### FUNCTION gdk_draw_layout_line ##### -->
 <para>
 
index d3f55f705b9572bca3ec3e250945f18346ed9253..87cfd71b0833b12ef1818bd17fba279cc834d6c6 100644 (file)
@@ -553,80 +553,6 @@ gdk_directfb_draw_rectangle (GdkDrawable *drawable,
     }
 }
 
-static void
-gdk_directfb_draw_polygon (GdkDrawable *drawable,
-                           GdkGC       *gc,
-                           gint         filled,
-                           GdkPoint    *points,
-                           gint         npoints)
-{
-  g_return_if_fail (GDK_IS_DRAWABLE (drawable));
-
-  D_DEBUG_AT( GDKDFB_Drawable, "%s( %p, %p, %s, %p, %d )\n", G_STRFUNC,
-              drawable, gc, filled ? " filled" : "outline", points, npoints );
-
-  if (npoints < 3)
-    return;
-
-  if (filled)
-    {
-      if (npoints == 3 || (npoints == 4 && 
-                                 points[0].x == points[npoints-1].x &&
-                                 points[0].y == points[npoints-1].y))
-          {
-            GdkDrawableImplDirectFB *impl;
-            cairo_region_t                clip;
-            gint                     i;
-
-            impl = GDK_DRAWABLE_IMPL_DIRECTFB (drawable);
-
-            if (!gdk_directfb_setup_for_drawing (impl, GDK_GC_DIRECTFB (gc)))
-              return;
-
-            gdk_directfb_clip_region (drawable, gc, NULL, &clip);
-
-            for (i = 0; i < clip.numRects; i++)
-              {
-                                DFBRegion reg = { clip.rects[i].x1,     clip.rects[i].y1, 
-                    clip.rects[i].x2 , clip.rects[i].y2  };
-
-                impl->surface->SetClip (impl->surface, &reg);
-                impl->surface->FillTriangle (impl->surface,
-                                             points[0].x, points[0].y,
-                                             points[1].x, points[1].y,
-                                             points[2].x, points[2].y);
-
-              }
-
-            temp_region_deinit( &clip );
-
-            return;
-          }
-                else
-                        g_message ("filled polygons with n > 3 are not yet supported, "
-                     "drawing outlines");
-    }
-
-  if (points[0].x != points[npoints-1].x ||
-      points[0].y != points[npoints-1].y)
-    {
-      GdkPoint *tmp_points;
-
-      tmp_points = g_new (GdkPoint, npoints + 1);
-      memcpy (tmp_points, points, npoints * sizeof (GdkPoint));
-      tmp_points[npoints].x = points[0].x;
-      tmp_points[npoints].y = points[0].y;
-
-      gdk_directfb_draw_lines (drawable, gc, tmp_points, npoints + 1);
-
-      g_free (tmp_points);
-    }
-  else
-    {
-      gdk_directfb_draw_lines (drawable, gc, points, npoints);
-    }
-}
-
 static void
 gdk_directfb_draw_drawable (GdkDrawable *drawable,
                             GdkGC       *gc,
@@ -973,7 +899,6 @@ gdk_drawable_impl_directfb_class_init (GdkDrawableImplDirectFBClass *klass)
 
   drawable_class->create_gc      = _gdk_directfb_gc_new;
   drawable_class->draw_rectangle = gdk_directfb_draw_rectangle;
-  drawable_class->draw_polygon   = gdk_directfb_draw_polygon;
   drawable_class->draw_drawable  = gdk_directfb_draw_drawable;
   drawable_class->draw_points    = gdk_directfb_draw_points;
   drawable_class->draw_segments  = gdk_directfb_draw_segments;
index f62bf7f1515bf0f995042e4aab39841b01415958..21604c8b4d2edf5cd4b48f0d20215f975714ce21 100644 (file)
@@ -554,7 +554,6 @@ gdk_draw_line
 gdk_draw_lines
 gdk_draw_point
 gdk_draw_points
-gdk_draw_polygon
 gdk_draw_rectangle
 gdk_draw_segments
 #endif
index 0a8532c54dbae3b6494f49ca83e567dfb86e36d5..8181cc1a89000f69ca68355b2975eae4e21b5639 100644 (file)
@@ -323,34 +323,6 @@ gdk_draw_rectangle (GdkDrawable *drawable,
                                                      width, height);
 }
 
-/**
- * gdk_draw_polygon:
- * @drawable: a #GdkDrawable (a #GdkWindow or a #GdkPixmap).
- * @gc: a #GdkGC.
- * @filled: %TRUE if the polygon should be filled. The polygon is closed
- *     automatically, connecting the last point to the first point if 
- *     necessary.
- * @points: an array of #GdkPoint structures specifying the points making 
- *     up the polygon.
- * @n_points: the number of points.
- * 
- * Draws an outlined or filled polygon.
- **/
-void
-gdk_draw_polygon (GdkDrawable    *drawable,
-                 GdkGC          *gc,
-                 gboolean        filled,
-                 const GdkPoint *points,
-                 gint            n_points)
-{
-  g_return_if_fail (GDK_IS_DRAWABLE (drawable));
-  g_return_if_fail (GDK_IS_GC (gc));
-
-  GDK_DRAWABLE_GET_CLASS (drawable)->draw_polygon (drawable, gc, filled,
-                                                   (GdkPoint *) points,
-                                                   n_points);
-}
-
 /**
  * gdk_draw_drawable:
  * @drawable: a #GdkDrawable
index 93d61c3e62598b3dc193d73f48ef0c39450d4209..151152c053018137c21274eacb456d46ec30542d 100644 (file)
@@ -67,11 +67,6 @@ struct _GdkDrawableClass
                          gint          y,
                          gint          width,
                          gint          height);
-  void (*draw_polygon)   (GdkDrawable  *drawable,
-                         GdkGC        *gc,
-                         gboolean      filled,
-                         GdkPoint     *points,
-                         gint          npoints);
   void (*draw_drawable)  (GdkDrawable  *drawable,
                          GdkGC        *gc,
                          GdkDrawable  *src,
@@ -184,11 +179,6 @@ void gdk_draw_rectangle (GdkDrawable      *drawable,
                         gint              y,
                         gint              width,
                         gint              height);
-void gdk_draw_polygon   (GdkDrawable      *drawable,
-                        GdkGC            *gc,
-                        gboolean          filled,
-                        const GdkPoint   *points,
-                        gint              n_points);
 void gdk_draw_drawable  (GdkDrawable      *drawable,
                         GdkGC            *gc,
                         GdkDrawable      *src,
index 91a438194668ba856f45c4de56b4ab103f9ed30b..9a21e0993e16aa431973ee4bf25d4f1bf861d7f3 100644 (file)
@@ -323,43 +323,6 @@ gdk_offscreen_window_draw_rectangle (GdkDrawable  *drawable,
 
 }
 
-static void
-gdk_offscreen_window_draw_polygon (GdkDrawable  *drawable,
-                                  GdkGC               *gc,
-                                  gboolean     filled,
-                                  GdkPoint     *points,
-                                  gint         npoints)
-{
-  GdkOffscreenWindow *offscreen = GDK_OFFSCREEN_WINDOW (drawable);
-  GdkDrawable *real_drawable = get_real_drawable (offscreen);
-
-  gdk_draw_polygon (real_drawable,
-                   gc,
-                   filled,
-                   points,
-                   npoints);
-
-  if (npoints > 0)
-    {
-      int min_x, min_y, max_x, max_y, i;
-
-      min_x = max_x = points[0].x;
-      min_y = max_y = points[0].y;
-
-       for (i = 1; i < npoints; i++)
-         {
-           min_x = MIN (min_x, points[i].x);
-           max_x = MAX (max_x, points[i].x);
-           min_y = MIN (min_y, points[i].y);
-           max_y = MAX (max_y, points[i].y);
-         }
-
-       add_damage (offscreen, min_x, min_y,
-                   max_x - min_x,
-                   max_y - min_y, !filled);
-    }
-}
-
 static void
 gdk_offscreen_window_draw_points (GdkDrawable  *drawable,
                                  GdkGC        *gc,
@@ -1083,7 +1046,6 @@ gdk_offscreen_window_class_init (GdkOffscreenWindowClass *klass)
   drawable_class->get_composite_drawable = gdk_offscreen_window_get_composite_drawable;
 
   drawable_class->draw_rectangle = gdk_offscreen_window_draw_rectangle;
-  drawable_class->draw_polygon = gdk_offscreen_window_draw_polygon;
   drawable_class->draw_drawable_with_src = gdk_offscreen_window_draw_drawable;
   drawable_class->draw_points = gdk_offscreen_window_draw_points;
   drawable_class->draw_segments = gdk_offscreen_window_draw_segments;
index 6915cd7ee2917b68a580dd9409f3fe210eb8e040..9d0465b561d58d7e604522687140d78c0f033373 100644 (file)
@@ -41,11 +41,6 @@ static void   gdk_pixmap_draw_rectangle (GdkDrawable     *drawable,
                                         gint             y,
                                         gint             width,
                                         gint             height);
-static void   gdk_pixmap_draw_polygon   (GdkDrawable     *drawable,
-                                        GdkGC           *gc,
-                                        gboolean         filled,
-                                        GdkPoint        *points,
-                                        gint             npoints);
 static void   gdk_pixmap_draw_drawable  (GdkDrawable     *drawable,
                                         GdkGC           *gc,
                                         GdkPixmap       *src,
@@ -127,7 +122,6 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass)
 
   drawable_class->create_gc = gdk_pixmap_create_gc;
   drawable_class->draw_rectangle = gdk_pixmap_draw_rectangle;
-  drawable_class->draw_polygon = gdk_pixmap_draw_polygon;
   drawable_class->draw_drawable_with_src = gdk_pixmap_draw_drawable;
   drawable_class->draw_points = gdk_pixmap_draw_points;
   drawable_class->draw_segments = gdk_pixmap_draw_segments;
@@ -226,19 +220,6 @@ gdk_pixmap_draw_rectangle (GdkDrawable *drawable,
                       x, y, width, height);
 }
 
-static void
-gdk_pixmap_draw_polygon (GdkDrawable *drawable,
-                        GdkGC       *gc,
-                        gboolean     filled,
-                        GdkPoint    *points,
-                        gint         npoints)
-{
-  GdkPixmapObject *private = (GdkPixmapObject *)drawable;
-
-  _gdk_gc_remove_drawable_clip (gc);  
-  gdk_draw_polygon (private->impl, gc, filled, points, npoints);
-}
-
 static void
 gdk_pixmap_draw_drawable (GdkDrawable *drawable,
                          GdkGC       *gc,
index 5be5f91c09b6964d1c387804f84b5f2f31632657..d6f2d7239336bdfbc323455c4fb3f7241e614c4e 100644 (file)
@@ -236,11 +236,6 @@ static void   gdk_window_draw_rectangle (GdkDrawable     *drawable,
                                         gint             y,
                                         gint             width,
                                         gint             height);
-static void   gdk_window_draw_polygon   (GdkDrawable     *drawable,
-                                        GdkGC           *gc,
-                                        gboolean         filled,
-                                        GdkPoint        *points,
-                                        gint             npoints);
 static void   gdk_window_draw_drawable  (GdkDrawable     *drawable,
                                         GdkGC           *gc,
                                         GdkPixmap       *src,
@@ -442,7 +437,6 @@ gdk_window_class_init (GdkWindowObjectClass *klass)
 
   drawable_class->create_gc = gdk_window_create_gc;
   drawable_class->draw_rectangle = gdk_window_draw_rectangle;
-  drawable_class->draw_polygon = gdk_window_draw_polygon;
   drawable_class->draw_drawable_with_src = gdk_window_draw_drawable;
   drawable_class->draw_points = gdk_window_draw_points;
   drawable_class->draw_segments = gdk_window_draw_segments;
@@ -3937,42 +3931,6 @@ gdk_window_draw_rectangle (GdkDrawable *drawable,
   END_DRAW;
 }
 
-static void
-gdk_window_draw_polygon (GdkDrawable *drawable,
-                        GdkGC       *gc,
-                        gboolean     filled,
-                        GdkPoint    *points,
-                        gint         npoints)
-{
-  GdkPoint *new_points;
-
-  if (GDK_WINDOW_DESTROYED (drawable))
-    return;
-
-  BEGIN_DRAW;
-
-  if (x_offset != 0 || y_offset != 0)
-    {
-      int i;
-
-      new_points = g_new (GdkPoint, npoints);
-      for (i=0; i<npoints; i++)
-       {
-         new_points[i].x = points[i].x - x_offset;
-         new_points[i].y = points[i].y - y_offset;
-       }
-    }
-  else
-    new_points = points;
-
-  gdk_draw_polygon (impl, gc, filled, new_points, npoints);
-
-  if (new_points != points)
-    g_free (new_points);
-
-  END_DRAW;
-}
-
 static GdkDrawable *
 gdk_window_get_source_drawable (GdkDrawable *drawable)
 {
index 6c77bb4874355a5d042c1096ba30f5f258ba0365..f7d365f047d76f62860ccc8db39004e953b61e7e 100644 (file)
@@ -184,46 +184,6 @@ gdk_quartz_draw_rectangle (GdkDrawable *drawable,
   gdk_quartz_drawable_release_context (drawable, context);
 }
 
-static void
-gdk_quartz_draw_polygon (GdkDrawable *drawable,
-                        GdkGC       *gc,
-                        gboolean     filled,
-                        GdkPoint    *points,
-                        gint         npoints)
-{
-  CGContextRef context = gdk_quartz_drawable_get_context (drawable, FALSE);
-  int i;
-
-  if (!context)
-    return;
-
-  _gdk_quartz_gc_update_cg_context (gc, drawable, context,
-                                   filled ?
-                                   GDK_QUARTZ_CONTEXT_FILL :
-                                   GDK_QUARTZ_CONTEXT_STROKE);
-
-  if (filled)
-    {
-      CGContextMoveToPoint (context, points[0].x, points[0].y);
-      for (i = 1; i < npoints; i++)
-       CGContextAddLineToPoint (context, points[i].x, points[i].y);
-
-      CGContextClosePath (context);
-      CGContextFillPath (context);
-    }
-  else
-    {
-      CGContextMoveToPoint (context, points[0].x + 0.5, points[0].y + 0.5);
-      for (i = 1; i < npoints; i++)
-       CGContextAddLineToPoint (context, points[i].x + 0.5, points[i].y + 0.5);
-
-      CGContextClosePath (context);
-      CGContextStrokePath (context);
-    }
-
-  gdk_quartz_drawable_release_context (drawable, context);
-}
-
 static void
 gdk_quartz_draw_drawable (GdkDrawable *drawable,
                          GdkGC       *gc,
@@ -455,7 +415,6 @@ gdk_drawable_impl_quartz_class_init (GdkDrawableImplQuartzClass *klass)
 
   drawable_class->create_gc = _gdk_quartz_gc_new;
   drawable_class->draw_rectangle = gdk_quartz_draw_rectangle;
-  drawable_class->draw_polygon = gdk_quartz_draw_polygon;
   drawable_class->draw_drawable_with_src = gdk_quartz_draw_drawable;
   drawable_class->draw_points = gdk_quartz_draw_points;
   drawable_class->draw_segments = gdk_quartz_draw_segments;
index 72a01f65e42fad4f7e8bf925aa28746c01e9afc6..4f6a562d41cf34ff53bb21938273ca9218b0845d 100644 (file)
@@ -55,11 +55,6 @@ static void gdk_win32_draw_rectangle (GdkDrawable    *drawable,
                                      gint            y,
                                      gint            width,
                                      gint            height);
-static void gdk_win32_draw_polygon   (GdkDrawable    *drawable,
-                                     GdkGC          *gc,
-                                     gboolean        filled,
-                                     GdkPoint       *points,
-                                     gint            npoints);
 static void gdk_win32_draw_drawable  (GdkDrawable    *drawable,
                                      GdkGC          *gc,
                                      GdkPixmap      *src,
@@ -113,7 +108,6 @@ _gdk_drawable_impl_win32_class_init (GdkDrawableImplWin32Class *klass)
 
   drawable_class->create_gc = _gdk_win32_gc_new;
   drawable_class->draw_rectangle = gdk_win32_draw_rectangle;
-  drawable_class->draw_polygon = gdk_win32_draw_polygon;
   drawable_class->draw_drawable_with_src = gdk_win32_draw_drawable;
   drawable_class->draw_points = gdk_win32_draw_points;
   drawable_class->draw_segments = gdk_win32_draw_segments;
@@ -772,91 +766,6 @@ gdk_win32_draw_rectangle (GdkDrawable *drawable,
   cairo_region_destroy (region);
 }
 
-static void
-draw_polygon (GdkGCWin32 *gcwin32,
-             HDC         hdc,
-             gint        x_offset,
-             gint        y_offset,
-             va_list     args)
-{
-  gboolean filled;
-  POINT *pts;
-  HGDIOBJ old_pen_or_brush;
-  gint npoints;
-  gint i;
-
-  filled = va_arg (args, gboolean);
-  pts = va_arg (args, POINT *);
-  npoints = va_arg (args, gint);
-
-  if (x_offset != 0 || y_offset != 0)
-    for (i = 0; i < npoints; i++)
-      {
-       pts[i].x -= x_offset;
-       pts[i].y -= y_offset;
-      }
-
-  if (filled)
-    old_pen_or_brush = SelectObject (hdc, GetStockObject (NULL_PEN));
-  else
-    old_pen_or_brush = SelectObject (hdc, GetStockObject (HOLLOW_BRUSH));
-  if (old_pen_or_brush == NULL)
-    WIN32_GDI_FAILED ("SelectObject");
-  GDI_CALL (Polygon, (hdc, pts, npoints));
-  if (old_pen_or_brush != NULL)
-    GDI_CALL (SelectObject, (hdc, old_pen_or_brush));
-}
-
-static void
-gdk_win32_draw_polygon (GdkDrawable *drawable,
-                       GdkGC       *gc,
-                       gboolean     filled,
-                       GdkPoint    *points,
-                       gint         npoints)
-{
-  GdkRectangle bounds;
-  cairo_region_t *region;
-  POINT *pts;
-  int i;
-
-  GDK_NOTE (DRAW, g_print ("gdk_win32_draw_polygon: %s %d points\n",
-                          _gdk_win32_drawable_description (drawable),
-                          npoints));
-
-  if (npoints < 2)
-    return;
-
-  bounds.x = G_MAXINT;
-  bounds.y = G_MAXINT;
-  bounds.width = 0;
-  bounds.height = 0;
-
-  pts = g_new (POINT, npoints);
-
-  for (i = 0; i < npoints; i++)
-    {
-      bounds.x = MIN (bounds.x, points[i].x);
-      bounds.y = MIN (bounds.y, points[i].y);
-      pts[i].x = points[i].x;
-      pts[i].y = points[i].y;
-    }
-
-  for (i = 0; i < npoints; i++)
-    {
-      bounds.width = MAX (bounds.width, points[i].x - bounds.x);
-      bounds.height = MAX (bounds.height, points[i].y - bounds.y);
-    }
-
-  region = widen_bounds (&bounds, GDK_GC_WIN32 (gc)->pen_width);
-
-  generic_draw (drawable, gc,
-               GDK_GC_FOREGROUND | (filled ? 0 : LINE_ATTRIBUTES),
-               draw_polygon, region, filled, pts, npoints);
-
-  cairo_region_destroy (region);
-  g_free (pts);
-}
-
 static void
 gdk_win32_draw_drawable (GdkDrawable *drawable,
                         GdkGC       *gc,
index be63bcc59643294c5fbba67616a5f4984b722485..b15637606178dc862e84adb1e27b47a7f631e853 100644 (file)
@@ -55,11 +55,6 @@ static void gdk_x11_draw_rectangle (GdkDrawable    *drawable,
                                    gint            y,
                                    gint            width,
                                    gint            height);
-static void gdk_x11_draw_polygon   (GdkDrawable    *drawable,
-                                   GdkGC          *gc,
-                                   gboolean        filled,
-                                   GdkPoint       *points,
-                                   gint            npoints);
 static void gdk_x11_draw_drawable  (GdkDrawable    *drawable,
                                    GdkGC          *gc,
                                    GdkPixmap      *src,
@@ -109,7 +104,6 @@ _gdk_drawable_impl_x11_class_init (GdkDrawableImplX11Class *klass)
   
   drawable_class->create_gc = _gdk_x11_gc_new;
   drawable_class->draw_rectangle = gdk_x11_draw_rectangle;
-  drawable_class->draw_polygon = gdk_x11_draw_polygon;
   drawable_class->draw_drawable_with_src = gdk_x11_draw_drawable;
   drawable_class->draw_points = gdk_x11_draw_points;
   drawable_class->draw_segments = gdk_x11_draw_segments;
@@ -330,50 +324,6 @@ gdk_x11_draw_rectangle (GdkDrawable *drawable,
                    GDK_GC_GET_XGC (gc), x, y, width, height);
 }
 
-static void
-gdk_x11_draw_polygon (GdkDrawable *drawable,
-                     GdkGC       *gc,
-                     gboolean     filled,
-                     GdkPoint    *points,
-                     gint         npoints)
-{
-  XPoint *tmp_points;
-  gint tmp_npoints, i;
-  GdkDrawableImplX11 *impl;
-
-  impl = GDK_DRAWABLE_IMPL_X11 (drawable);
-
-  
-  if (!filled &&
-      (points[0].x != points[npoints-1].x || points[0].y != points[npoints-1].y))
-    {
-      tmp_npoints = npoints + 1;
-      tmp_points = g_new (XPoint, tmp_npoints);
-      tmp_points[npoints].x = points[0].x;
-      tmp_points[npoints].y = points[0].y;
-    }
-  else
-    {
-      tmp_npoints = npoints;
-      tmp_points = g_new (XPoint, tmp_npoints);
-    }
-
-  for (i=0; i<npoints; i++)
-    {
-      tmp_points[i].x = points[i].x;
-      tmp_points[i].y = points[i].y;
-    }
-  
-  if (filled)
-    XFillPolygon (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
-                 GDK_GC_GET_XGC (gc), tmp_points, tmp_npoints, Complex, CoordModeOrigin);
-  else
-    XDrawLines (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
-               GDK_GC_GET_XGC (gc), tmp_points, tmp_npoints, CoordModeOrigin);
-
-  g_free (tmp_points);
-}
-
 static void
 gdk_x11_draw_drawable (GdkDrawable *drawable,
                       GdkGC       *gc,